package com.business.systemmanage.service.Impl;

import com.business.systemmanage.common.cont.CommonCont;
import com.business.systemmanage.entity.ItemClass;
import com.business.systemmanage.mapper.ItemClassMapper;
import com.business.systemmanage.service.IItemClassService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.business.systemmanage.vo.ItemClassVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 * 菜品分类 服务实现类
 * </p>
 *
 * @author sixDog
 * @since 2019-04-12
 */
@Service
public class ItemClassServiceImpl extends ServiceImpl<ItemClassMapper, ItemClass> implements IItemClassService {

    @Override
    public void insert(ItemClassVO itemClassVO) {
        ItemClass itemClass = new ItemClass();
        BeanUtils.copyProperties(itemClassVO,itemClass);
        if(itemClass.getClassFatherId()== CommonCont.NO) {
            itemClass.setIsParent((long)CommonCont.YES);
        } else {
            itemClass.setIsParent((long)CommonCont.NO);
        }
        itemClass.setModifyTime(LocalDateTime.now());
        itemClass.setCreateTime(LocalDateTime.now());
        this.save(itemClass);
    }
}
